package com.reins.bookstore.repository;

import com.reins.bookstore.entity.Orders;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

public interface OrderRepository extends JpaRepository<Orders,Integer> {

    @Query(value = "select * from Orders where order_time >= :frontDate and order_time <= :backDate",nativeQuery = true)
    List<Orders> findAllByDate(Date frontDate, Date backDate);

    @Query(value = "select * from Orders where user_id = :id ",nativeQuery = true)
    List<Orders> findAllOrdersByUserId(Integer id);

    @Query(value = "select * from Orders where user_id = :id and order_time >= :frontDate and order_time <= :backDate ",nativeQuery = true)
    List<Orders> findAllOrdersByUserId(Integer id, Date frontDate, Date backDate);

    @Query(value = "select * from Orders where order_time >= :frontDate and order_time <= :backDate",nativeQuery = true)
    List<Orders> filterByDate(Date frontDate, Date backDate);
}
